<admintpl file="header"/>
<style>
    .status {
        background-color: #eeeeee;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li
        <eq name="ACTION_NAME" value="index">class="active"</eq>
        ><a href="{:U('FailuresRepair/index')}">{:L('ALL')}</a></li>
        <li
        <eq name="ACTION_NAME" value="all_no_order">class="active"</eq>
        ><a href="{:U('FailuresRepair/all_no_order')}" target="_self">{:L('ALL_NO_ORDER')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="all_no_handle">class="active"</eq>
        ><a href="{:U('FailuresRepair/all_no_handle')}" target="_self">{:L('ALL_NO_HANDLE')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="all_handled">class="active"</eq>
        ><a href="{:U('FailuresRepair/all_handled')}" target="_self">{:L('ALL_HANDLED')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="self_orders">class="active"</eq>
        ><a href="{:U('FailuresRepair/self_orders')}" target="_self">{:L('OWN_HEAD_ALL')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="self_no_order">class="active"</eq>
        ><a href="{:U('FailuresRepair/self_no_order')}" target="_self">{:L('OWN_HEAD_NO_ORDER')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="self_no_handle">class="active"</eq>
        ><a href="{:U('FailuresRepair/self_no_handle')}" target="_self">{:L('OWN_HEAD_NO_HANDLE')}</a>
        </li>
        <li
        <eq name="ACTION_NAME" value="self_handled">class="active"</eq>
        ><a href="{:U('FailuresRepair/self_handled')}" target="_self">{:L('OWN_HEAD_HANDLE')}</a>
        </li>
    </ul>
    <eq name="ACTION_NAME" value="index">
        <form class="well form-search" method="post" action="{:U('FailuresRepair/index')}">
            校区：
            <select class="select_2" id="campus_select" name="campus">
                <option value='0'>全部</option>
                {$select_campus}
            </select> &nbsp;&nbsp;
            区域：
            <select class="select_2" id="building_select" name="building">
                <option value='0'>全部</option>
                {$select_building}
            </select> &nbsp;&nbsp;
            运营商：
            <select class="select_2" name="operator">
                <option value='0'>全部</option>
                {$select_operator}
            </select> &nbsp;&nbsp;
            <br>
            <br>
            报修时间：
            <input type="text" name="start_time" class="js-date" value="{$formget.start_time|default=''}"
                   style="width: 80px;" autocomplete="off">-
            <input type="text" class="js-date" name="end_time" value="{$formget.end_time}" style="width: 80px;"
                   autocomplete="off"> &nbsp; &nbsp;
            姓名：
            <input type="text" name="name" style="width: 200px;" value="{$formget.name|default=''}"
                   placeholder="请输入姓名...">
            <input type="submit" class="btn btn-primary" value="搜索"/>
        </form>
    </eq>
    <form class="js-ajax-form" action="" method="post">
        <div class="table-actions">
            <button class="btn btn-primary btn-small js-ajax-submit" type="submit"
                    data-action="{:U('AdminPost/delete')}" data-subcheck="true" data-msg="你确定删除吗？">{:L('DELETE')}
            </button>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="60">{:L('NAME')}</th>
                <th>{:L('MOBILE')}</th>
                <th width="70">{:L('CAMPUS')}</th>
                <th width="70">{:L('BUILDING')}</th>
                <th width="30">{:L('ROOM_NUMBER')}</th>
                <th width="50">{:L('OPERATOR')}</th>
                <th width="50">{:L('ACCOUNT')}</th>
                <th width="60">{:L('FAULT_TYPE')}</th>
                <th width="120">{:L('DESCRIPTION')}</th>
                <th style="min-width: 60px">{:L('CREATION_TIME')}</th>
                <th width="60" class="status">{:L('STATUS')}</th>
                <th width="50" class="status">{:L('ORDER_USER')}</th>
                <th style="min-width: 60px" class="status">{:L('ORDER_TIME')}</th>
                <th width="100">{:L('ACTIONS')}</th>
            </tr>
            </thead>
            <foreach name="failures_repair" item="vo">
                <tr>
                    <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.tid}" title="ID:{$vo.tid}"></td>
                    <td><a href="{:U('FailuresRepair/details',array('id'=>$vo['id']))}">{$vo.name}</a></td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.campus_title}</td>
                    <td>{$vo.building_title}</td>
                    <td>{$vo.room_number}</td>
                    <td>{$vo.operator_title}</td>
                    <td>{$vo.account}</td>
                    <td>{$vo.fault_type_title}</td>
                    <td>{$vo.description}</td>
                    <td>{:date('Y-m-d h:i:s',$vo['creation_time'])}</td>
                    <td>
                        <switch name="vo.status">
                            <case value="">未接单</case>
                            <case value="0">未接单</case>
                            <case value="1">未处理</case>
                            <case value="2">已处理</case>
                        </switch>
                    </td>
                    <td>{$vo.admin_name}</td>
                    <td>
                        <notempty name="vo.order_time">
                            {:date('Y-m-d h:i:s',$vo['order_time'])}
                        </notempty>
                    </td>
                    <td>
                        <eq name="vo.user_id" value="$_SESSION['ADMIN_ID']">
                            <a href="{:U('FailuresRepair/details',array('id'=>$vo['id']))}" target="_blank">{:L('CHECK')}</a>
                            |
                            <else/>
                            <eq name="Think.session.ADMIN_ID" value="1">
                                <a href="{:U('FailuresRepair/details',array('id'=>$vo['id']))}" target="_blank">{:L('CHECK')}</a>
                                |
                                <else/>
                                <a href="{:U('FailuresRepair/details',array('id'=>$vo['id']))}">{:L('CHECK')}</a> |
                            </eq>
                        </eq>
                        <!--<empty name="vo.status">-->
                        <!--<a href="#">{:L('ORDER')}</a> |-->
                        <!--</empty>-->
                        <switch name="vo.status">
                            <case value="">
                                <a href="{:U('FailuresRepair/orders',array('id'=>$vo['id']))}" class="js-ajax-orders">{:L('ORDER')}</a>
                                |
                            </case>
                            <case value="1">
                                <eq name="vo.user_id" value="$_SESSION['ADMIN_ID']">
                                    <a href="{:U('FailuresRepair/exchange',array('id'=>$vo['id']))}">转单</a>
                                    |
                                    <a href="{:U('FailuresRepair/handle',array('id'=>$vo['id']))}">处理</a>
                                    |
                                    <else/>
                                    <eq name="Think.session.ADMIN_ID" value="1">
                                        <a href="{:U('AdminPost/edit',array('term'=>empty($term['term_id'])?'':$term['term_id'],'id'=>$vo['id']))}">转单</a>
                                        |
                                        <a href="{:U('FailuresRepair/handle',array('id'=>$vo['id']))}">处理</a>
                                        |
                                    </eq>
                                </eq>
                            </case>
                        </switch>
                        <a href="{:U('FailuresRepair/delete',array('id'=>$vo['id']))}"
                           class="js-ajax-delete">{:L('DELETE')}</a></td>
                </tr>
            </foreach>
            <tfoot>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="60">{:L('NAME')}</th>
                <th>{:L('MOBILE')}</th>
                <th width="70">{:L('CAMPUS')}</th>
                <th width="70">{:L('BUILDING')}</th>
                <th width="30">{:L('ROOM_NUMBER')}</th>
                <th width="50">{:L('OPERATOR')}</th>
                <th width="50">{:L('ACCOUNT')}</th>
                <th width="60">{:L('FAULT_TYPE')}</th>
                <th width="120">{:L('DESCRIPTION')}</th>
                <th style="min-width: 60px">{:L('CREATION_TIME')}</th>
                <th width="60" class="status">{:L('STATUS')}</th>
                <th width="50" class="status">{:L('ORDER_USER')}</th>
                <th style="min-width: 60px" class="status">{:L('ORDER_TIME')}</th>
                <th width="100">{:L('ACTIONS')}</th>
            </tr>
            </tfoot>
        </table>
        <div class="table-actions">
            <button class="btn btn-primary btn-small js-ajax-submit" type="submit"
                    data-action="{:U('AdminPost/delete')}" data-subcheck="true" data-msg="你确定删除吗？">{:L('DELETE')}
            </button>
        </div>
        <div class="pagination">{$Page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    function refersh_window() {
        var refersh_time = getCookie('refersh_time');
        if (refersh_time == 1) {
            window.location = "{:U('FailuresRepair/index',$formget)}";
        }
    }
    setInterval(function () {
        refersh_window();
    }, 2000);

    $(function () {

        $("#campus_select").change(function () {
            $.post("{:U('get_building')}", {'campus': $(this).val()}, function (data, status) {
                console.log(data);
                $('#building_select').empty();
                $('#building_select').append("<option value='0'>全部</option>");
                $('#building_select').append(data.data);
            });
        });

        setCookie("refersh_time", 0);
        Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
            //批量移动
            $('.js-articles-move').click(function (e) {
                var str = 0;
                var id = tag = '';
                $("input[name='ids[]']").each(function () {
                    if ($(this).attr('checked')) {
                        str = 1;
                        id += tag + $(this).val();
                        tag = ',';
                    }
                });
                if (str == 0) {
                    art.dialog.through({
                        id: 'error',
                        icon: 'error',
                        content: '您没有勾选信息，无法进行操作！',
                        cancelVal: '关闭',
                        cancel: true
                    });
                    return false;
                }
                var $this = $(this);
                art.dialog.open("__ROOT__/index.php?g=portal&m=AdminPost&a=move&ids=" + id, {
                    title: "批量移动",
                    width: "80%"
                });
            });
        });
    });
</script>
</body>
</html>